//
//  SCNewFeatureCell.m
//  SCGoJD
//
//  Created by mac on 15/9/22.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "SCNewFeatureCell.h"
#import "NewLoginViewController.h"

@interface SCNewFeatureCell ()

@property (nonatomic, weak) UIButton *startButton;

@end

@implementation SCNewFeatureCell

- (UIButton *)startButton {
    
    if (_startButton == nil) {
        
        UIButton *tempStartButton = [UIButton buttonWithType:UIButtonTypeCustom];
        
//        // 设置图片
//        [tempStartButton setImage:[UIImage imageNamed:@"functionGuideBt1"]
//                                   forState:UIControlStateNormal];
//        [tempStartButton setImage:[UIImage imageNamed:@"functionGuideBt2"]
//                                   forState:UIControlStateHighlighted];
        
        // 尺寸自适应
        [tempStartButton sizeToFit];
        
        // 添加点击事件
        [tempStartButton addTarget:self
                            action:@selector(startJD:)
                  forControlEvents:UIControlEventTouchUpInside];
        
        
        [self addSubview:tempStartButton];
        
        _startButton = tempStartButton;
    }
    
    return _startButton;
}

#pragma mark - 获取当前页码和最后一页的页码,判断是否显示按钮
- (void)setCurrentPageIndex:(NSInteger)currentIndex lastPageIndex:(NSInteger)lastIndex
{
    
    if (currentIndex == lastIndex)
    { // 如果是最后一页就显示button
        
        self.startButton.hidden = NO;
        
    } else {
        
        self.startButton.hidden = YES;
    }
}

#pragma mark  - 点击开始按钮时调用
- (void)startJD:(UIButton *)button {

    NewLoginViewController *vc = [[NewLoginViewController alloc]init];

    kKeyWindow.rootViewController = vc;
    [kKeyWindow.window makeKeyAndVisible];
 }

#pragma mark - 布局子控件
- (void)layoutSubviews {
    
    [super layoutSubviews];
    // 设置开始按钮中心
    self.startButton.frame = CGRectMake(SCREEN_WIDTH/2-100*kUIScaleBasePlus,SCREEN_HEIGHT-60*kUIScaleBasePlus,200*kUIScaleBasePlus,50*kUIScaleBasePlus);

}

@end
